package com.leapp.sk.viewdelegate.notify

import android.content.Intent
import android.text.TextUtils
import android.view.View
import android.widget.ListView
import android.widget.TextView
import com.example.mvp.delegate.BaseAppDelegate
import com.example.mvp.view.SKTopBar
import com.example.mvp.view.video.VideoActivity
import com.leapp.sk.R
import com.leapp.sk.bean.NotifyObjEntity
import com.leapp.sk.ui.activity.im.MessageStateActivity
import com.leapp.sk.ui.activity.im.SingleChatActivity
import com.leapp.sk.ui.activity.login.PerfectUserInfoActivity
import com.leapp.sk.ui.activity.notify.NotifyActivity
import com.leapp.sk.ui.adapter.NotifyAdapter

/**
 * @author  chaohaipeng  on 2018/7/26.
 */
class NotifyDelegate: BaseAppDelegate() {
    /**
     * 适配器
     */
    var mAdapter:NotifyAdapter?=null
    override fun initWidget() {

    }

    override fun initLayoutRes(): Int {
        return R.layout.activity_notify
    }
    /**
     * 设置标题
     */
    fun setTitle(title:String?){
        val topBar= getView<SKTopBar>(R.id.jtb_an)
        if (!TextUtils.isEmpty(title)){
            topBar?.setTitle(title)
        }
        setEvent(topBar)
    }

    /**
     * 初始化适配器
     */
    fun initAdapter(list:List<NotifyObjEntity>){
        val lv_an_lsit= getView<ListView>(R.id.lv_an_lsit)
        mAdapter= NotifyAdapter(getActivity(),list,false)
        lv_an_lsit.adapter=mAdapter
        lv_an_lsit.setOnItemClickListener{adapterView, view, i, l ->
            val intent: Intent = Intent(getActivity<NotifyActivity>(), MessageStateActivity::class.java)
            getActivity<NotifyActivity>().startActivity(intent)


        }

    }
    /**
     * 设置设置事件
     */
  private  fun setEvent(topBar:SKTopBar){
        topBar?.setEventInterface(object : SKTopBar.EventInterface{
            override fun leftOnClick() {
                getActivity<NotifyActivity>().finish()

            }
            override fun rightOnClick() {
            }

        })
    }


}